package com.huluobo.module_risk_level.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import com.huluobo.appbase.network.HttpErrorDeal
import com.huluobo.module_risk_level.repo.RiskLevelRepo
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow

/**
 * Created by lc on 2022/12/30.
 */
class RiskLevelViewModel : ViewModel() {

    fun loadRiskLevelMessage() = flow {
        val data = RiskLevelRepo().loadRiskLevelMessage()
        emit(data)
    }.catch {
        if (it is Exception) {
            HttpErrorDeal.dealHttpError(it)
        }
        emit(null)
    }.asLiveData()
}